﻿namespace AC.ExtendedRenderer.Toolkit.Charting
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Windows.Forms;

    public class AquaGauge : UserControl
    {
        private Color _centerPointColor = Color.Black;
        private bool _centerPointRotateEnable = true;
        private CenterPointSizes _centerPointSize = CenterPointSizes.Normal;
        private CenterPointTypes _centerPointType = CenterPointTypes.Round;
        private float _currentValue;
        private Color _dialColor = Color.Lavender;
        private string _dialText;
        private Font _dialTextFont;
        private Color _digitBackPanelBorderColor = Color.Gray;
        private bool _digitBackPanelBorderEnabled;
        private Color _digitBackPanelColor = Color.Gray;
        private bool _digitBackPanelEnabled;
        private Color _digitColor = Color.Black;
        private bool _enableTransparentBackground;
        private Color _externalRimColor = Color.SlateGray;
        private float _glossinessAlpha = 75f;
        private Color _handColor = Color.Black;
        private bool _handOverCenterPoint;
        private HandTypes _handType = HandTypes.Normal;
        private Color _internalRimColor = Color.Gainsboro;
        private float _maxValue;
        private int _miminumSize = 140;
        private float _minValue;
        private int _noOfDivisions;
        private int _noOfSubDivisions;
        private float _recommendedValue;
        private Color _thickCalibrationColor = Color.Black;
        private Color _thinCalibrationColor = Color.Black;
        private float _threshold;
        private Color _thresholdColor = Color.LawnGreen;
        private Image backgroundImg;
        private IContainer components;
        private float fromAngle = 135f;
        private int height;
        private Rectangle rectImg;
        private bool requiresRedraw;
        private float toAngle = 405f;
        private int width;
        private int x;
        private int y;

        public AquaGauge()
        {
            this.InitializeComponent();
            this.x = 8;
            this.y = 8;
            this.width = base.Width - 15;
            this.height = base.Height - 15;
            this._noOfDivisions = 10;
            this._noOfSubDivisions = 3;
            this._dialTextFont = this.Font;
            base.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            base.SetStyle(ControlStyles.ResizeRedraw, true);
            base.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            base.SetStyle(ControlStyles.UserPaint, true);
            base.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            this.BackColor = Color.Transparent;
            this.requiresRedraw = true;
        }

        private void AquaGauge_Resize()
        {
            if ((base.Width < this._miminumSize) || (base.Width < this._miminumSize))
            {
                base.Width = this._miminumSize;
                base.Height = this._miminumSize;
            }
            if (base.Width > base.Height)
            {
                base.Width = base.Height;
                this.width = this.height;
            }
            if (base.Height > base.Width)
            {
                base.Height = base.Width;
                this.height = this.width;
            }
        }

        private void DisplayNumber(Graphics g, float number, RectangleF drect)
        {
            try
            {
                string str = number.ToString("000.00");
                str.PadLeft(3, '0');
                float num = 0f;
                if (number < 0f)
                {
                    num -= this.width / 0x11;
                }
                bool dp = false;
                char[] chArray = str.ToCharArray();
                for (int i = 0; i < chArray.Length; i++)
                {
                    char ch = chArray[i];
                    if ((i < (chArray.Length - 1)) && (chArray[i + 1] == '.'))
                    {
                        dp = true;
                    }
                    else
                    {
                        dp = false;
                    }
                    switch (ch)
                    {
                        case '.':
                            goto Label_00DA;

                        case '-':
                            this.DrawDigit(g, -1, new PointF(drect.X + num, drect.Y), dp, drect.Height);
                            break;

                        default:
                            this.DrawDigit(g, short.Parse(ch.ToString()), new PointF(drect.X + num, drect.Y), dp, drect.Height);
                            break;
                    }
                    num += (15 * this.width) / 250;
                    continue;
                Label_00DA:
                    num += (2 * this.width) / 250;
                }
            }
            catch (Exception)
            {
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void DrawCalibration(Graphics g, Rectangle rect, int cX, int cY)
        {
            int num = this._noOfDivisions + 1;
            int num2 = this._noOfSubDivisions;
            float radian = this.GetRadian(this.fromAngle);
            int num4 = (int) (base.Width * 0.01f);
            float num5 = base.Width / 0x19;
            Rectangle rectangle = new Rectangle(rect.Left + num4, rect.Top + num4, rect.Width - num4, rect.Height - num4);
            float num12 = (rectangle.Width / 2) - (num4 * 5);
            float num13 = this.toAngle - this.fromAngle;
            float num14 = this.GetRadian(num13 / ((float) ((num - 1) * (num2 + 1))));
            Pen pen = new Pen(this._thickCalibrationColor, (float) (base.Width / 50));
            Pen pen2 = new Pen(this._thinCalibrationColor, (float) (base.Width / 100));
            float minValue = this.MinValue;
            for (int i = 0; i <= num; i++)
            {
                float num6 = (float) (cX + (num12 * Math.Cos((double) radian)));
                float num7 = (float) (cY + (num12 * Math.Sin((double) radian)));
                float num8 = (float) (cX + ((num12 - (base.Width / 20)) * Math.Cos((double) radian)));
                float num9 = (float) (cY + ((num12 - (base.Width / 20)) * Math.Sin((double) radian)));
                g.DrawLine(pen, num6, num7, num8, num9);
                new StringFormat();
                float x = (float) (cX + ((num12 - (base.Width / 10)) * Math.Cos((double) radian)));
                float y = (cY - num5) + ((float) ((num12 - (base.Width / 10)) * Math.Sin((double) radian)));
                Brush brush = new SolidBrush(this.ForeColor);
                StringFormat format = new StringFormat(StringFormatFlags.NoClip);
                format.Alignment = StringAlignment.Center;
                Font font = new Font(this.Font.FontFamily, (float) (base.Width / 0x17), this.Font.Style);
                g.DrawString(minValue.ToString() ?? "", font, brush, new PointF(x, y), format);
                minValue += (this.MaxValue - this.MinValue) / ((float) (num - 1));
                minValue = (float) Math.Round((double) minValue, 2);
                if (i == (num - 1))
                {
                    return;
                }
                for (int j = 0; j <= num2; j++)
                {
                    radian += num14;
                    num6 = (float) (cX + (num12 * Math.Cos((double) radian)));
                    num7 = (float) (cY + (num12 * Math.Sin((double) radian)));
                    num8 = (float) (cX + ((num12 - (base.Width / 50)) * Math.Cos((double) radian)));
                    num9 = (float) (cY + ((num12 - (base.Width / 50)) * Math.Sin((double) radian)));
                    g.DrawLine(pen2, num6, num7, num8, num9);
                }
            }
        }

        private void DrawCenterPoint(Graphics g, Rectangle rect, int cX, int cY, float angle)
        {
            Matrix matrix = new Matrix();
            Point point = new Point(cX, cY);
            GraphicsState gstate = g.Save();
            if (this._centerPointRotateEnable)
            {
                matrix.RotateAt(angle, (PointF) point);
                g.Transform = matrix;
            }
            float width = base.Width / 7;
            float num2 = base.Width / 9;
            switch (this._centerPointSize)
            {
                case CenterPointSizes.Normal:
                    width = base.Width / 7;
                    num2 = base.Width / 9;
                    break;

                case CenterPointSizes.Medium:
                    width = base.Width / 9;
                    num2 = base.Width / 12;
                    break;

                case CenterPointSizes.Small:
                    width = base.Width / 11;
                    num2 = base.Width / 14;
                    break;

                case CenterPointSizes.Smaller:
                    width = base.Width / 20;
                    num2 = base.Width / 30;
                    break;
            }
            RectangleF ef = new RectangleF(cX - (width / 2f), cY - (width / 2f), width, width);
            LinearGradientBrush brush = new LinearGradientBrush(rect, this._centerPointColor, Color.FromArgb(100, this._dialColor), LinearGradientMode.Vertical);
            RectangleF ef2 = new RectangleF(cX - (num2 / 2f), cY - (num2 / 2f), num2, num2);
            LinearGradientBrush brush2 = new LinearGradientBrush(rect, Color.SlateGray, this._centerPointColor, LinearGradientMode.ForwardDiagonal);
            switch (this._centerPointType)
            {
                case CenterPointTypes.Round:
                    g.FillEllipse(brush, ef);
                    g.FillEllipse(brush2, ef2);
                    break;

                case CenterPointTypes.Square:
                    g.FillRectangle(brush, ef);
                    g.FillRectangle(brush2, ef2);
                    break;
            }
            if (this._centerPointRotateEnable)
            {
                matrix.Invert();
                matrix.RotateAt(-angle, (PointF) point);
                g.Restore(gstate);
            }
            brush2.Dispose();
            brush.Dispose();
        }

        private void DrawDigit(Graphics g, int number, PointF position, bool dp, float height)
        {
            float width = (10f * height) / 13f;
            Pen pen = new Pen(Color.FromArgb(40, this._dialColor));
            Pen pen2 = new Pen(this._digitColor);
            PointF[] points = new PointF[5];
            points[0] = points[4] = new PointF(position.X + this.GetX(2.8f, width), position.Y + this.GetY(1f, height));
            points[1] = new PointF(position.X + this.GetX(10f, width), position.Y + this.GetY(1f, height));
            points[2] = new PointF(position.X + this.GetX(8.8f, width), position.Y + this.GetY(2f, height));
            points[3] = new PointF(position.X + this.GetX(3.8f, width), position.Y + this.GetY(2f, height));
            PointF[] tfArray2 = new PointF[5];
            tfArray2[0] = tfArray2[4] = new PointF(position.X + this.GetX(10f, width), position.Y + this.GetY(1.4f, height));
            tfArray2[1] = new PointF(position.X + this.GetX(9.3f, width), position.Y + this.GetY(6.8f, height));
            tfArray2[2] = new PointF(position.X + this.GetX(8.4f, width), position.Y + this.GetY(6.4f, height));
            tfArray2[3] = new PointF(position.X + this.GetX(9f, width), position.Y + this.GetY(2.2f, height));
            PointF[] tfArray3 = new PointF[5];
            tfArray3[0] = tfArray3[4] = new PointF(position.X + this.GetX(9.2f, width), position.Y + this.GetY(7.2f, height));
            tfArray3[1] = new PointF(position.X + this.GetX(8.7f, width), position.Y + this.GetY(12.7f, height));
            tfArray3[2] = new PointF(position.X + this.GetX(7.6f, width), position.Y + this.GetY(11.9f, height));
            tfArray3[3] = new PointF(position.X + this.GetX(8.2f, width), position.Y + this.GetY(7.7f, height));
            PointF[] tfArray4 = new PointF[5];
            tfArray4[0] = tfArray4[4] = new PointF(position.X + this.GetX(7.4f, width), position.Y + this.GetY(12.1f, height));
            tfArray4[1] = new PointF(position.X + this.GetX(8.4f, width), position.Y + this.GetY(13f, height));
            tfArray4[2] = new PointF(position.X + this.GetX(1.3f, width), position.Y + this.GetY(13f, height));
            tfArray4[3] = new PointF(position.X + this.GetX(2.2f, width), position.Y + this.GetY(12.1f, height));
            PointF[] tfArray5 = new PointF[5];
            tfArray5[0] = tfArray5[4] = new PointF(position.X + this.GetX(2.2f, width), position.Y + this.GetY(11.8f, height));
            tfArray5[1] = new PointF(position.X + this.GetX(1f, width), position.Y + this.GetY(12.7f, height));
            tfArray5[2] = new PointF(position.X + this.GetX(1.7f, width), position.Y + this.GetY(7.2f, height));
            tfArray5[3] = new PointF(position.X + this.GetX(2.8f, width), position.Y + this.GetY(7.7f, height));
            PointF[] tfArray6 = new PointF[5];
            tfArray6[0] = tfArray6[4] = new PointF(position.X + this.GetX(3f, width), position.Y + this.GetY(6.4f, height));
            tfArray6[1] = new PointF(position.X + this.GetX(1.8f, width), position.Y + this.GetY(6.8f, height));
            tfArray6[2] = new PointF(position.X + this.GetX(2.6f, width), position.Y + this.GetY(1.3f, height));
            tfArray6[3] = new PointF(position.X + this.GetX(3.6f, width), position.Y + this.GetY(2.2f, height));
            PointF[] tfArray7 = new PointF[7];
            tfArray7[0] = tfArray7[6] = new PointF(position.X + this.GetX(2f, width), position.Y + this.GetY(7f, height));
            tfArray7[1] = new PointF(position.X + this.GetX(3.1f, width), position.Y + this.GetY(6.5f, height));
            tfArray7[2] = new PointF(position.X + this.GetX(8.3f, width), position.Y + this.GetY(6.5f, height));
            tfArray7[3] = new PointF(position.X + this.GetX(9f, width), position.Y + this.GetY(7f, height));
            tfArray7[4] = new PointF(position.X + this.GetX(8.2f, width), position.Y + this.GetY(7.5f, height));
            tfArray7[5] = new PointF(position.X + this.GetX(2.9f, width), position.Y + this.GetY(7.5f, height));
            g.FillPolygon(pen.Brush, points);
            g.FillPolygon(pen.Brush, tfArray2);
            g.FillPolygon(pen.Brush, tfArray3);
            g.FillPolygon(pen.Brush, tfArray4);
            g.FillPolygon(pen.Brush, tfArray5);
            g.FillPolygon(pen.Brush, tfArray6);
            g.FillPolygon(pen.Brush, tfArray7);
            int[] listOfNumbers = new int[8];
            listOfNumbers[1] = 2;
            listOfNumbers[2] = 3;
            listOfNumbers[3] = 5;
            listOfNumbers[4] = 6;
            listOfNumbers[5] = 7;
            listOfNumbers[6] = 8;
            listOfNumbers[7] = 9;
            if (this.IsNumberAvailable(number, listOfNumbers))
            {
                g.FillPolygon(pen2.Brush, points);
            }
            int[] numArray2 = new int[8];
            numArray2[1] = 1;
            numArray2[2] = 2;
            numArray2[3] = 3;
            numArray2[4] = 4;
            numArray2[5] = 7;
            numArray2[6] = 8;
            numArray2[7] = 9;
            if (this.IsNumberAvailable(number, numArray2))
            {
                g.FillPolygon(pen2.Brush, tfArray2);
            }
            int[] numArray3 = new int[9];
            numArray3[1] = 1;
            numArray3[2] = 3;
            numArray3[3] = 4;
            numArray3[4] = 5;
            numArray3[5] = 6;
            numArray3[6] = 7;
            numArray3[7] = 8;
            numArray3[8] = 9;
            if (this.IsNumberAvailable(number, numArray3))
            {
                g.FillPolygon(pen2.Brush, tfArray3);
            }
            int[] numArray4 = new int[7];
            numArray4[1] = 2;
            numArray4[2] = 3;
            numArray4[3] = 5;
            numArray4[4] = 6;
            numArray4[5] = 8;
            numArray4[6] = 9;
            if (this.IsNumberAvailable(number, numArray4))
            {
                g.FillPolygon(pen2.Brush, tfArray4);
            }
            int[] numArray5 = new int[4];
            numArray5[1] = 2;
            numArray5[2] = 6;
            numArray5[3] = 8;
            if (this.IsNumberAvailable(number, numArray5))
            {
                g.FillPolygon(pen2.Brush, tfArray5);
            }
            int[] numArray6 = new int[7];
            numArray6[1] = 4;
            numArray6[2] = 5;
            numArray6[3] = 6;
            numArray6[4] = 7;
            numArray6[5] = 8;
            numArray6[6] = 9;
            if (this.IsNumberAvailable(number, numArray6))
            {
                g.FillPolygon(pen2.Brush, tfArray6);
            }
            if (this.IsNumberAvailable(number, new int[] { 2, 3, 4, 5, 6, 8, 9, -1 }))
            {
                g.FillPolygon(pen2.Brush, tfArray7);
            }
            if (dp)
            {
                g.FillEllipse(pen2.Brush, new RectangleF(position.X + this.GetX(10f, width), position.Y + this.GetY(12f, height), width / 7f, width / 7f));
            }
        }

        private void DrawGloss(Graphics g)
        {
            RectangleF rect = new RectangleF(this.x + ((float) (this.width * 0.1)), this.y + ((float) (this.height * 0.07)), (float) (this.width * 0.8), (float) (this.height * 0.7));
            LinearGradientBrush brush = new LinearGradientBrush(rect, Color.FromArgb((int) this._glossinessAlpha, Color.White), Color.Transparent, LinearGradientMode.Vertical);
            g.FillEllipse(brush, rect);
            rect = new RectangleF(this.x + ((float) (this.width * 0.25)), this.y + ((float) (this.height * 0.77)), (float) (this.width * 0.5), (float) (this.height * 0.2));
            int alpha = (int) (this._glossinessAlpha / 3f);
            brush = new LinearGradientBrush(rect, Color.Transparent, Color.FromArgb(alpha, this.BackColor), LinearGradientMode.Vertical);
            g.FillEllipse(brush, rect);
            brush.Dispose();
        }

        private void DrawPointer(Graphics gr, int cx, int cy)
        {
            float num = (base.Width / 2) - (base.Width * 0.12f);
            float angle = this.MaxValue - this.MinValue;
            Image image = new Bitmap(base.Width, base.Height);
            Graphics g = Graphics.FromImage(image);
            g.SmoothingMode = SmoothingMode.AntiAlias;
            angle = (100f * (this._currentValue - this.MinValue)) / angle;
            angle = ((this.toAngle - this.fromAngle) * angle) / 100f;
            angle += this.fromAngle;
            if (this._handOverCenterPoint)
            {
                Rectangle rect = new Rectangle(this.x, this.y, this.width, this.height);
                this.DrawCenterPoint(g, rect, (this.width / 2) + this.x, (this.height / 2) + this.y, angle);
            }
            float radian = this.GetRadian(angle);
            PointF[] points = new PointF[5];
            double num4 = 0.02;
            float num5 = 0.09f;
            switch (this._handType)
            {
                case HandTypes.Normal:
                    num4 = 0.02;
                    num5 = 0.09f;
                    break;

                case HandTypes.Medium:
                    num4 = 0.01;
                    num5 = 0.045f;
                    break;

                case HandTypes.Small:
                    num4 = 0.001;
                    num5 = 0.01f;
                    break;
            }
            points[0].X = (float) (cx + (num * Math.Cos((double) radian)));
            points[0].Y = (float) (cy + (num * Math.Sin((double) radian)));
            points[4].X = (float) (cx + (num * Math.Cos(radian - num4)));
            points[4].Y = (float) (cy + (num * Math.Sin(radian - num4)));
            radian = this.GetRadian(angle + 20f);
            points[1].X = (float) (cx + ((base.Width * num5) * Math.Cos((double) radian)));
            points[1].Y = (float) (cy + ((base.Width * num5) * Math.Sin((double) radian)));
            points[2].X = cx;
            points[2].Y = cy;
            radian = this.GetRadian(angle - 20f);
            points[3].X = (float) (cx + ((base.Width * num5) * Math.Cos((double) radian)));
            points[3].Y = (float) (cy + ((base.Width * num5) * Math.Sin((double) radian)));
            Brush brush = new SolidBrush(this._handColor);
            g.FillPolygon(brush, points);
            PointF[] tfArray2 = new PointF[3];
            radian = this.GetRadian(angle);
            tfArray2[0].X = (float) (cx + (num * Math.Cos((double) radian)));
            tfArray2[0].Y = (float) (cy + (num * Math.Sin((double) radian)));
            radian = this.GetRadian(angle + 20f);
            tfArray2[1].X = (float) (cx + ((base.Width * num5) * Math.Cos((double) radian)));
            tfArray2[1].Y = (float) (cy + ((base.Width * num5) * Math.Sin((double) radian)));
            tfArray2[2].X = cx;
            tfArray2[2].Y = cy;
            LinearGradientBrush brush2 = new LinearGradientBrush(tfArray2[0], tfArray2[2], Color.SlateGray, this._handColor);
            g.FillPolygon(brush2, tfArray2);
            if (!this._handOverCenterPoint)
            {
                Rectangle rectangle2 = new Rectangle(this.x, this.y, this.width, this.height);
                this.DrawCenterPoint(g, rectangle2, (this.width / 2) + this.x, (this.height / 2) + this.y, angle);
            }
            this.DrawGloss(g);
            gr.DrawImage(image, 0, 0);
        }

        public float GetRadian(float theta)
        {
            return ((theta * 3.141593f) / 180f);
        }

        private float GetX(float x, float width)
        {
            return ((x * width) / 12f);
        }

        private float GetY(float y, float height)
        {
            return ((y * height) / 15f);
        }

        private void InitializeComponent()
        {
            base.SuspendLayout();
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.Name = "AquaGauge";
            base.ResumeLayout(false);
        }

        private bool IsNumberAvailable(int number, params int[] listOfNumbers)
        {
            if (listOfNumbers.Length > 0)
            {
                foreach (int num in listOfNumbers)
                {
                    if (num == number)
                    {
                        return true;
                    }
                }
            }
            return false;
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            this.width = base.Width - (this.x * 2);
            this.height = base.Height - (this.y * 2);
            this.DrawPointer(e.Graphics, (this.width / 2) + this.x, (this.height / 2) + this.y);
        }

        protected override void OnPaintBackground(PaintEventArgs e)
        {
            if (!this._enableTransparentBackground)
            {
                base.OnPaintBackground(e);
            }
            e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
            e.Graphics.FillRectangle(new SolidBrush(Color.Transparent), new Rectangle(0, 0, base.Width, base.Height));
            if ((this.backgroundImg == null) || this.requiresRedraw)
            {
                this.backgroundImg = new Bitmap(base.Width, base.Height);
                Graphics g = Graphics.FromImage(this.backgroundImg);
                g.SmoothingMode = SmoothingMode.HighQuality;
                this.width = base.Width - (this.x * 2);
                this.height = base.Height - (this.y * 2);
                this.rectImg = new Rectangle(this.x, this.y, this.width, this.height);
                Brush brush = new SolidBrush(Color.FromArgb(120, this._dialColor));
                if (this._enableTransparentBackground && (base.Parent != null))
                {
                    int num1 = this.width / 60;
                }
                g.FillEllipse(brush, this.x, this.y, this.width, this.height);
                SolidBrush brush2 = new SolidBrush(Color.FromArgb(100, this._externalRimColor));
                Pen pen = new Pen(brush2, (float) (this.width * 0.03));
                g.DrawEllipse(pen, this.rectImg);
                Pen pen2 = new Pen(this._externalRimColor);
                g.DrawEllipse(pen2, this.x, this.y, this.width, this.height);
                this.DrawCalibration(g, this.rectImg, (this.width / 2) + this.x, (this.height / 2) + this.y);
                Pen pen3 = new Pen(Color.FromArgb(190, this._internalRimColor), (float) (base.Width / 40));
                new Pen(Color.FromArgb(250, Color.Black), (float) (base.Width / 200));
                int num = (int) (base.Width * 0.03f);
                Rectangle rect = new Rectangle(this.rectImg.X + num, this.rectImg.Y + num, this.rectImg.Width - (num * 2), this.rectImg.Height - (num * 2));
                g.DrawArc(pen3, rect, 135f, 270f);
                pen3 = new Pen(Color.FromArgb(200, this._thresholdColor), (float) (base.Width / 50));
                rect = new Rectangle(this.rectImg.X + num, this.rectImg.Y + num, this.rectImg.Width - (num * 2), this.rectImg.Height - (num * 2));
                float num2 = this.MaxValue - this.MinValue;
                num2 = (100f * (this._recommendedValue - this.MinValue)) / num2;
                num2 = ((this.toAngle - this.fromAngle) * num2) / 100f;
                num2 += this.fromAngle;
                float startAngle = num2 - ((270f * this._threshold) / 200f);
                if (startAngle <= 135f)
                {
                    startAngle = 135f;
                }
                float sweepAngle = (270f * this._threshold) / 100f;
                if ((startAngle + sweepAngle) > 405f)
                {
                    sweepAngle = 405f - startAngle;
                }
                g.DrawArc(pen3, rect, startAngle, sweepAngle);
                RectangleF ef = new RectangleF((((float) base.Width) / 2f) - (((float) this.width) / 5f), ((float) this.height) / 1.2f, ((float) this.width) / 2.5f, ((float) base.Height) / 9f);
                RectangleF drect = new RectangleF((float) ((base.Width / 2) - (this.width / 7)), (float) ((int) (((double) this.height) / 1.18)), (float) (this.width / 4), (float) (base.Height / 12));
                if (this._digitBackPanelEnabled)
                {
                    g.FillRectangle(new SolidBrush(Color.FromArgb(90, this._digitBackPanelColor)), ef);
                    if (this._digitBackPanelBorderEnabled)
                    {
                        g.DrawRectangle(new Pen(Color.FromArgb(120, this._digitBackPanelBorderColor)), ef.X, ef.Y, ef.Width, ef.Height);
                    }
                }
                this.DisplayNumber(g, this._currentValue, drect);
                g.SmoothingMode = SmoothingMode.AntiAlias;
                SizeF ef3 = g.MeasureString(this._dialText, this._dialTextFont);
                RectangleF layoutRectangle = new RectangleF((base.Width / 2) - (ef3.Width / 2f), (float) ((int) (((double) this.height) / 1.5)), ef3.Width, ef3.Height);
                g.DrawString(this._dialText, this._dialTextFont, new SolidBrush(this.ForeColor), layoutRectangle);
                this.requiresRedraw = false;
            }
            e.Graphics.DrawImage(this.backgroundImg, this.rectImg);
        }

        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);
            this.AquaGauge_Resize();
            this.requiresRedraw = true;
            this.Refresh();
        }

        [Description("Color of the Hand"), Category("Appearance-Extended"), Browsable(true)]
        public Color CenterPointColor
        {
            get
            {
                return this._centerPointColor;
            }
            set
            {
                this._centerPointColor = value;
                this.requiresRedraw = true;
                base.Invalidate();
            }
        }

        [Category("Appearance-Extended"), Browsable(true), Description("Center Point Type")]
        public bool CenterPointRotateEnable
        {
            get
            {
                return this._centerPointRotateEnable;
            }
            set
            {
                this._centerPointRotateEnable = value;
                this.requiresRedraw = true;
                base.Invalidate();
            }
        }

        [Description("Center Point Type"), Category("Appearance-Extended"), Browsable(true)]
        public CenterPointSizes CenterPointSize
        {
            get
            {
                return this._centerPointSize;
            }
            set
            {
                this._centerPointSize = value;
                this.requiresRedraw = true;
                base.Invalidate();
            }
        }

        [Description("Center Point Type"), Category("Appearance-Extended"), Browsable(true)]
        public CenterPointTypes CenterPointType
        {
            get
            {
                return this._centerPointType;
            }
            set
            {
                this._centerPointType = value;
                this.requiresRedraw = true;
                base.Invalidate();
            }
        }

        protected override System.Windows.Forms.CreateParams CreateParams
        {
            get
            {
                System.Windows.Forms.CreateParams createParams = base.CreateParams;
                createParams.ExStyle |= 0x20;
                return createParams;
            }
        }

        [Description("Background color of the dial"), Browsable(true), Category("Appearance-Extended")]
        public Color DialColor
        {
            get
            {
                return this._dialColor;
            }
            set
            {
                this._dialColor = value;
                this.requiresRedraw = true;
                base.Invalidate();
            }
        }

        [Description("Gets or Sets the Text to be displayed in the dial"), Browsable(true), Category("Appearance-Extended")]
        public string DialText
        {
            get
            {
                return this._dialText;
            }
            set
            {
                this._dialText = value;
                this.requiresRedraw = true;
                base.Invalidate();
            }
        }

        [Browsable(true), Description("Color of the Hand"), Category("Appearance-Extended")]
        public Font DialTextFont
        {
            get
            {
                return this._dialTextFont;
            }
            set
            {
                this._dialTextFont = value;
                this.requiresRedraw = true;
                base.Invalidate();
            }
        }

        [Browsable(true), Category("Appearance-Extended"), Description("Color Digit Back Panel")]
        public Color DigitBackPanelBorderColor
        {
            get
            {
                return this._digitBackPanelBorderColor;
            }
            set
            {
                this._digitBackPanelBorderColor = value;
                this.requiresRedraw = true;
                base.Invalidate();
            }
        }

        [Category("Appearance-Extended"), Description("Show Digit BackPanel Border"), Browsable(true), DefaultValue(true)]
        public bool DigitBackPanelBorderEnabled
        {
            get
            {
                return this._digitBackPanelBorderEnabled;
            }
            set
            {
                this._digitBackPanelBorderEnabled = value;
                this.requiresRedraw = true;
                base.Invalidate();
            }
        }

        [Category("Appearance-Extended"), Description("Color Digit Back Panel"), Browsable(true)]
        public Color DigitBackPanelColor
        {
            get
            {
                return this._digitBackPanelColor;
            }
            set
            {
                this._digitBackPanelColor = value;
                this.requiresRedraw = true;
                base.Invalidate();
            }
        }

        [Description("Show Digit BackPanel"), Browsable(true), Category("Appearance-Extended"), DefaultValue(true)]
        public bool DigitBackPanelEnabled
        {
            get
            {
                return this._digitBackPanelEnabled;
            }
            set
            {
                this._digitBackPanelEnabled = value;
                this.requiresRedraw = true;
                base.Invalidate();
            }
        }

        [Description("Color of the Hand"), Browsable(true), Category("Appearance-Extended")]
        public Color DigitColor
        {
            get
            {
                return this._digitColor;
            }
            set
            {
                this._digitColor = value;
                this.requiresRedraw = true;
                base.Invalidate();
            }
        }

        [Category("Appearance-Extended"), Description("Enables or Disables Transparent Background color. Note: Enabling this will reduce the performance and may make the control flicker."), Browsable(true), DefaultValue(false)]
        public bool EnableTransparentBackground
        {
            get
            {
                return this._enableTransparentBackground;
            }
            set
            {
                this._enableTransparentBackground = value;
                base.SetStyle(ControlStyles.OptimizedDoubleBuffer, !this._enableTransparentBackground);
                this.requiresRedraw = true;
                this.Refresh();
            }
        }

        [Browsable(true), Category("Appearance-Extended"), Description("Color of the Hand")]
        public Color ExternalRimColor
        {
            get
            {
                return this._externalRimColor;
            }
            set
            {
                this._externalRimColor = value;
                this.requiresRedraw = true;
                base.Invalidate();
            }
        }

        [Category("Appearance-Extended"), Browsable(true), Description("Glossiness strength. Range: 0-100"), DefaultValue(0x4b)]
        public float Glossiness
        {
            get
            {
                return ((this._glossinessAlpha * 100f) / 220f);
            }
            set
            {
                float num = value;
                if (num > 100f)
                {
                    value = 100f;
                }
                if (num < 0f)
                {
                    value = 0f;
                }
                this._glossinessAlpha = (value * 220f) / 100f;
                this.Refresh();
            }
        }

        [Browsable(true), Category("Appearance-Extended"), Description("Color of the Hand")]
        public Color HandColor
        {
            get
            {
                return this._handColor;
            }
            set
            {
                this._handColor = value;
                this.requiresRedraw = true;
                base.Invalidate();
            }
        }

        [Category("Appearance-Extended"), Description("Draw Hand over CenterPoint"), Browsable(true)]
        public bool HandOverCenterPoint
        {
            get
            {
                return this._handOverCenterPoint;
            }
            set
            {
                this._handOverCenterPoint = value;
                this.requiresRedraw = true;
                base.Invalidate();
            }
        }

        [Category("Appearance-Extended"), Browsable(true), Description("Hand Type")]
        public HandTypes HandType
        {
            get
            {
                return this._handType;
            }
            set
            {
                this._handType = value;
                this.requiresRedraw = true;
                base.Invalidate();
            }
        }

        [Category("Appearance-Extended"), Browsable(true), Description("Color of the Hand")]
        public Color InternalRimColor
        {
            get
            {
                return this._internalRimColor;
            }
            set
            {
                this._internalRimColor = value;
                this.requiresRedraw = true;
                base.Invalidate();
            }
        }

        [Category("Appearance-Extended"), Browsable(true), Description("Maximum value on the scale"), DefaultValue(100)]
        public float MaxValue
        {
            get
            {
                return this._maxValue;
            }
            set
            {
                if (value > this._minValue)
                {
                    this._maxValue = value;
                    if (this._currentValue > this._maxValue)
                    {
                        this._currentValue = this._maxValue;
                    }
                    if (this._recommendedValue > this._maxValue)
                    {
                        this._recommendedValue = this._maxValue;
                    }
                    this.requiresRedraw = true;
                    base.Invalidate();
                }
            }
        }

        [Browsable(true), Category("Appearance-Extended"), Description("Minimum Size")]
        public int MiminumSize
        {
            get
            {
                return this._miminumSize;
            }
            set
            {
                this._miminumSize = value;
                this.requiresRedraw = true;
                base.Invalidate();
            }
        }

        [DefaultValue(0), Description("Mininum value on the scale"), Browsable(true), Category("Appearance-Extended")]
        public float MinValue
        {
            get
            {
                return this._minValue;
            }
            set
            {
                if (value < this._maxValue)
                {
                    this._minValue = value;
                    if (this._currentValue < this._minValue)
                    {
                        this._currentValue = this._minValue;
                    }
                    if (this._recommendedValue < this._minValue)
                    {
                        this._recommendedValue = this._minValue;
                    }
                    this.requiresRedraw = true;
                    base.Invalidate();
                }
            }
        }

        [Description("Get or Sets the number of Divisions in the dial scale."), Category("Appearance-Extended"), Browsable(true), DefaultValue(10)]
        public int NoOfDivisions
        {
            get
            {
                return this._noOfDivisions;
            }
            set
            {
                if ((value > 1) && (value < 0x19))
                {
                    this._noOfDivisions = value;
                    this.requiresRedraw = true;
                    base.Invalidate();
                }
            }
        }

        [DefaultValue(3), Browsable(true), Category("Appearance-Extended"), Description("Gets or Sets the number of Sub Divisions in the scale per Division.")]
        public int NoOfSubDivisions
        {
            get
            {
                return this._noOfSubDivisions;
            }
            set
            {
                if ((value > 0) && (value <= 10))
                {
                    this._noOfSubDivisions = value;
                    this.requiresRedraw = true;
                    base.Invalidate();
                }
            }
        }

        [Browsable(true), Description("Threshold value from which green area will be marked."), DefaultValue(0x19), Category("Appearance-Extended")]
        public float RecommendedValue
        {
            get
            {
                return this._recommendedValue;
            }
            set
            {
                if ((value > this._minValue) && (value < this._maxValue))
                {
                    this._recommendedValue = value;
                    this.requiresRedraw = true;
                    base.Invalidate();
                }
            }
        }

        [Description("Color of the Hand"), Browsable(true), Category("Appearance-Extended")]
        public Color ThickCalibrationColor
        {
            get
            {
                return this._thickCalibrationColor;
            }
            set
            {
                this._thickCalibrationColor = value;
                this.requiresRedraw = true;
                base.Invalidate();
            }
        }

        [Browsable(true), Category("Appearance-Extended"), Description("Color of the Hand")]
        public Color ThinCalibrationColor
        {
            get
            {
                return this._thinCalibrationColor;
            }
            set
            {
                this._thinCalibrationColor = value;
                this.requiresRedraw = true;
                base.Invalidate();
            }
        }

        [Browsable(true), Category("Appearance-Extended"), Description("Color of the Hand")]
        public Color ThresholdColor
        {
            get
            {
                return this._thresholdColor;
            }
            set
            {
                this._thresholdColor = value;
                this.requiresRedraw = true;
                base.Invalidate();
            }
        }

        [Category("Appearance-Extended"), Description("Gets or Sets the Threshold area from the Recommended Value. (1-99%)"), DefaultValue(0x19), Browsable(true)]
        public float ThresholdPercent
        {
            get
            {
                return this._threshold;
            }
            set
            {
                if ((value > 0f) && (value < 100f))
                {
                    this._threshold = value;
                    this.requiresRedraw = true;
                    base.Invalidate();
                }
            }
        }

        [Browsable(true), Description("Value where the pointer will point to."), DefaultValue(0), Category("Appearance-Extended")]
        public float Value
        {
            get
            {
                return this._currentValue;
            }
            set
            {
                if ((value >= this._minValue) && (value <= this._maxValue))
                {
                    this._currentValue = value;
                    this.requiresRedraw = true;
                    this.Refresh();
                }
            }
        }

        public enum CenterPointSizes
        {
            Medium = 2,
            Normal = 1,
            Small = 3,
            Smaller = 4
        }

        public enum CenterPointTypes
        {
            Round = 1,
            Square = 2
        }

        public enum HandTypes
        {
            Medium = 2,
            Normal = 1,
            Small = 3
        }
    }
}

